package org.example.service.Impl;

import org.example.bean.Orders;
import org.example.bean.Search;
import org.example.mapper.OrdersMapper;
import org.example.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrdersServiceImpl implements OrdersService {
    @Autowired
    OrdersMapper ordersMapper;
    @Override
    public List<Orders> ordersAll() {
        return ordersMapper.ordersAll();
    }


    @Override
    public List<Orders> ordersType(String o_type,Integer page,Integer pageSize) {
        return ordersMapper.ordersType(o_type,page,pageSize);
    }

    @Override
    public Integer total(String oType) {
        return ordersMapper.total(oType);
    }

    @Override
    public Integer update(String oType,Integer oId) {
        return ordersMapper.update(oType,oId);
    }

    @Override
    public List<Orders> searchAll(Search search) {
        return ordersMapper.searchAll(search);
    }

    @Override
    public List<Orders> jy(String type,Integer oId) {
        return ordersMapper.jy(type,oId);
    }

    @Override
    public boolean fuel(Integer oId, Integer[] f ,String[] breeds) {
        for (int i=0;i<f.length;i++){
            ordersMapper.fuel(oId,f[i],breeds[i]);
        }
        return true;
    }

    @Override
    public boolean pf(Integer oId, Integer oil, Integer serve, Integer other) {
        return ordersMapper.pf(oId,oil,serve,other)>0;
    }

    @Override
    public boolean yc(Integer oId, String info) {
        return ordersMapper.yc(oId,info)>0;
    }

    @Override
    public boolean complete(Integer oId, Integer[] ff, String[] breeds) {
        for (int i=0;i<ff.length;i++){
            ordersMapper.fuel(oId,ff[i],breeds[i]);
        }
        ordersMapper.status(oId);
        return true;
    }

    @Override
    public List<Orders> ordersTypeScore(String supplier,String oType, Integer page, Integer pageSize) {
        return ordersMapper.ordersTypeScore(supplier.trim(),oType.trim(),page,pageSize);
    }

    @Override
    public Integer totalScore(String supplier, String oType) {

        return ordersMapper.totalScore(supplier.trim(),oType.trim());
    }

    @Override
    public Integer totalThen() {
        return ordersMapper.totalThen();
    }

    @Override
    public List<Orders> searchAllThen(Search search) {
        return ordersMapper.searchAllThen(search);
    }

    @Override
    public List<Orders> ordersTypeThen(String oType, Integer page, Integer pageSize) {
        return ordersMapper.ordersTypeThen(oType,page,pageSize);
    }

    @Override
    public Orders idSer(Integer oId) {
        return ordersMapper.idSer(oId);
    }

    @Override
    public Integer updateSupplier(Integer oId, String supplier) {

        return ordersMapper.updateSupplier(oId,supplier);
    }


}
